import {Modal,Form,Input} from 'antd'

import React ,{ Component }  from 'react'

const FormItem = Form.Item;

class FromModel extends Component{
  constructor(props){
    super(props);
    this.state={
    }
    this.handleSubmit=this.handleSubmit.bind(this)
    this.handleCancel=this.handleCancel.bind(this)
  }
  handleOk(e){
    this.handleSubmit(e);
  }
  handleCancel(){
    this.props.Cancel()
  }
  handleSubmit(e){
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (!err) {
        this.props.click(values)
      }else{
        
      }
    });
  }
  render(){
    const { getFieldDecorator } = this.props.form;
    return(
      <Modal title="提示" visible={this.props.visible} onOk={(e)=>this.handleOk(e)} onCancel={this.handleCancel} okText="确定"  cancelText="取消">
      <Form onSubmit={this.handleSubmit}>
        <FormItem label="网站名称"  labelCol={{ span: 5 }} wrapperCol={{ span: 12 }}>
          {getFieldDecorator('name', {
            rules: [{ required: true, message: '网站名称不能为空' }],
            initialValue:this.props.upValue
          })(
            <Input placeholder="输入网站名称"  defaultValue="123"/>
          )}
        </FormItem>
        <FormItem label="网站域名" labelCol={{ span: 5 }} wrapperCol={{ span: 12 }} >
          {getFieldDecorator('domain', {
            rules: [{ required: true, message: '网站域名不能为空'}],
            initialValue:this.props.upDomain
          })(
            <Input placeholder="输入网站域名"/>
          )}
        </FormItem>
      </Form>
    </Modal>
    )
  }
}
const WrappedApp = Form.create()(FromModel);

export default WrappedApp